#!/usr/bin/env sh

. ${HOME}/.config/scripts/color/i3blocks-usage-color.sh

read USED_MEM TOTAL_MEM PERCENTAGE < <(
  free | awk '/Mem:/ {printf "%.1f %.1f %.0f", $3/1048576, $2/1048576, $3/$2*100}'
)

ICON="\Uefc5"

if [ "${PERCENTAGE}" -lt "40" ] ; then
    ICON_COLOR=${VERY_LOW_USAGE_COLOR}
elif [ "${PERCENTAGE}" -lt "60" ] ; then
    ICON_COLOR=${LOW_USAGE_COLOR}
elif [ "${PERCENTAGE}" -lt "80" ] ; then
    ICON_COLOR=${MIDDLE_USAGE_COLOR}
else
    ICON_COLOR=${HIGH_USAGE_COLOR}
fi

echo -e "${ICON} ${USED_MEM}/${TOTAL_MEM}Gi\n\n${ICON_COLOR}"

